package myLucene;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.zip.GZIPOutputStream;

import matrics.SparseVector;

public class SerializeSparseVectorArray {
	public static String write(SparseVector[] ar, String fileName) throws IOException {
		System.out.println("Serialize object " +fileName+" "+ GetTime.getTime());
		long start = System.currentTimeMillis();
		// Write to disk with FileOutputStream
		FileOutputStream f_out = new FileOutputStream(fileName);

		// Write object with ObjectOutputStream
		GZIPOutputStream out= new GZIPOutputStream(f_out);
		ObjectOutputStream obj_out = new ObjectOutputStream(out);
		
		// Write object out to disk
		obj_out.writeObject(ar);
		obj_out.flush();
		obj_out.close();
		System.out.println("Serialize done ...time needed "
				+ GetTime.getDuration(start, System.currentTimeMillis()));
		return fileName;
	}

}
